home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 6 / CU Amiga Magazine's Super CD-ROM 06 (1996)(EMAP Images)(GB)(Track 1 of 4)[!][issue 1997-01].iso / cucd / prog / gnu-c / man / cat1 / sh.0 < prev    next >
Text File  |  1995-08-24  |  42KB  |  1,189 lines

  1.  
  2.  
  3.  sh(C)                                06       January       1993
  4. sh(C)
  5.  
  6.  
  7.  _N_a_m_e
  8.  
  9.     sh - invoke the shell command interpreter
  10.  
  11.  _S_y_n_t_a_x
  12.  
  13.     sshh [ --aacceeiikknnrrssttuuvvxx ] [ _aa_rr_gg_ss ]
  14.  
  15.  _D_e_s_c_r_i_p_t_i_o_n
  16.  
  17.     The shell is the standard command programming  language  that
  18. executes com-
  19.     mands  read  from  a  terminal or a file.  See ``Invocation''
  20. below for the
  21.     meaning of arguments to the shell.
  22.  
  23.     _C_o_m_m_a_n_d_s
  24.  
  25.     A _s_i_m_p_l_e-_c_o_m_m_a_n_d is a sequence of nonblank _w_o_r_d_s separated by
  26. _b_l_a_n_k_s (a
  27.     _b_l_a_n_k  is  a  tab  or a space).  The first word specifies the
  28. name of the
  29.     command to be  executed.   Except  as  specified  below,  the
  30. remaining words
  31.     are  passed as arguments to the invoked command.  The command
  32. name is
  33.     passed as argument 0 (see eexxeecc(S)).  The _v_a_l_u_e of  a  simple-
  34. command is its
  35.     exit status if it terminates normally, or (octal) 1000+_ss_tt_aa_tt_uu_ss
  36. if it ter-
  37.     minates abnormally. See ssiiggnnaall(S) for a list of  status  val-
  38. ues.
  39.  
  40.     A _p_i_p_e_l_i_n_e is a sequence of one or more _c_o_m_m_a_n_d_s separated by
  41. a vertical
  42.     bar (||).  (The caret (^^), is an obsolete synonym for the ver-
  43. tical bar and
  44.     should not be used in a pipeline.  Scripts that use ``^'' for
  45. pipelines
  46.     are incompatible with the Korn shell.)  The  standard  output
  47. of each com-
  48.     mand  but  the last is connected by a ppiippee(S) to the standard
  49. input of the
  50.     next command.  Each command is run as a separate process; the
  51. shell waits
  52.     for the last command to terminate.
  53.  
  54.     A _l_i_s_t is a sequence of one or more pipelines separated by ;;,
  55. &&, &&&&, or
  56.     ||||, and optionally terminated by ;; or &&.  Of these four  sym-
  57. bols, ;; and &&
  58.     have equal precedence, which is lower than that of &&&& and ||||.
  59. The sym-
  60.     bols &&&& and |||| also have equal precedence.  A  semicolon  (;;)
  61. causes
  62.     sequential  execution of the preceding pipeline; an ampersand
  63. (&&) causes
  64.     asynchronous execution of the preceding  pipeline  (that  is,
  65. the shell does
  66.     _n_o_t  wait  for  that pipeline to finish).  The symbol &&&& (||||)
  67. causes the
  68.     _l_i_s_t following it  to  be  executed  only  if  the  preceding
  69. pipeline returns a
  70.     zero  (nonzero) exit status.  An arbitrary number of newlines
  71. may appear
  72.     in a _l_i_s_t, instead of semicolons, to delimit commands.
  73.  
  74.     A _c_o_m_m_a_n_d is either a simple-command or one of the  following
  75. commands.
  76.     Unless  otherwise  stated, the value returned by a command is
  77. that of the
  78.     last simple-command executed in the command:
  79.  
  80.     ffoorr _nn_aa_mm_ee [ iinn _ww_oo_rr_dd ... ]
  81.     ddoo
  82.             _ll_ii_ss_tt
  83.     ddoonnee
  84.  
  85.     Each time a ffoorr command is executed, _nn_aa_mm_ee is set to the  next
  86. _ww_oo_rr_dd taken
  87.     from  the  iinn _ww_oo_rr_dd list.  If iinn _ww_oo_rr_dd is omitted, then the ffoorr
  88. command exe-
  89.     cutes the ddoo _ll_ii_ss_tt once for each positional parameter that  is
  90. set (see
  91.     ``Parameter substitution'' below).  Execution ends when there
  92. are no more
  93.     words in the list.
  94.  
  95.  
  96.     ccaassee _ww_oo_rr_dd iinn
  97.     [ _pp_aa_tt_tt_ee_rr_nn [ | _pp_aa_tt_tt_ee_rr_nn ] ... )) _ll_ii_ss_tt
  98.                                     ;;;; ]
  99.     eessaacc
  100.  
  101.     A ccaassee command executes the _ll_ii_ss_tt associated  with  the  first
  102. _pp_aa_tt_tt_ee_rr_nn that
  103.     matches  _ww_oo_rr_dd.   The form of the patterns is the same as that
  104. used for
  105.     filename generation (see ``Filename generation'' below).
  106.  
  107.  
  108.     iiff _ll_ii_ss_tt
  109.     tthheenn
  110.             _ll_ii_ss_tt
  111.     [ eelliiff _ll_ii_ss_tt tthheenn
  112.             _ll_ii_ss_tt ]
  113.     ...
  114.     [ eellssee _ll_ii_ss_tt ]
  115.     ffii
  116.  
  117.     The _ll_ii_ss_tt following iiff is executed and, if it returns  a  zero
  118. exit status,
  119.     the  _ll_ii_ss_tt  following  the first tthheenn is executed.  Otherwise,
  120. the _ll_ii_ss_tt fol-
  121.     lowing eelliiff is executed and, if its value is zero,  the  _ll_ii_ss_tt
  122. following the
  123.     next  tthheenn  is executed.  Failing that, the eellssee _ll_ii_ss_tt is exe-
  124. cuted.  If no
  125.     eellssee _ll_ii_ss_tt or tthheenn _ll_ii_ss_tt  is  executed,  then  the  iiff  command
  126. returns a zero
  127.     exit status.
  128.  
  129.  
  130.     wwhhiillee _ll_ii_ss_tt
  131.     ddoo
  132.             _ll_ii_ss_tt
  133.     ddoonnee
  134.  
  135.     A  wwhhiillee  command  repeatedly executes the wwhhiillee _ll_ii_ss_tt and, if
  136. the exit
  137.     status of the last command in the list is zero, executes  the
  138. ddoo _ll_ii_ss_tt;
  139.     otherwise the loop terminates.  If no commands in the ddoo _ll_ii_ss_tt
  140. are exe-
  141.     cuted, then the wwhhiillee command returns  a  zero  exit  status;
  142. uunnttiill may be
  143.     used in place of wwhhiillee to negate the loop termination test.
  144.  
  145.  
  146.     uunnttiill _ll_ii_ss_tt
  147.     ddoo
  148.             _ll_ii_ss_tt
  149.     ddoonnee
  150.  
  151.     uunnttiill  is  similar  to  wwhhiillee, only uunnttiill continues execution
  152. until the first
  153.     _ll_ii_ss_tt returns a zero exit status.  In other words, uunnttiill works
  154. until the
  155.     test  condition succeeds (it works the whole time the command
  156. is failing);
  157.     wwhhiillee works until the test condition fails. uunnttiill  is  useful
  158. when you are
  159.     waiting for a particular event to occur.
  160.  
  161.  
  162.     ((_ll_ii_ss_tt))
  163.  
  164.     Executes _ll_ii_ss_tt in a subshell.
  165.  
  166.  
  167.     {{_ll_ii_ss_tt;;}}
  168.  
  169.     _ll_ii_ss_tt is simply executed.
  170.  
  171.  
  172.     _nn_aa_mm_ee (()) {{_ll_ii_ss_tt;;}}
  173.  
  174.     Define  a  function which is referenced by _nn_aa_mm_ee.  The body of
  175. functions is
  176.     the _ll_ii_ss_tt of commands between {{ and }}.  Execution of functions
  177. is
  178.     described later (see ``Execution''.)
  179.  
  180.     The  following words are recognized only as the first word of
  181. a command
  182.     and when not quoted:
  183.  
  184.     iiff      tthheenn    eellssee    eelliiff    ffii      ccaassee    eessaacc
  185.     ffoorr     wwhhiillee   uunnttiill   ddoo      ddoonnee    {{       }}
  186.  
  187.     _C_o_m_m_e_n_t_s
  188.  
  189.     A word beginning with ## causes that word and all the  follow-
  190. ing characters
  191.     up to a newline to be ignored.
  192.  
  193.     _C_o_m_m_a_n_d _s_u_b_s_t_i_t_u_t_i_o_n
  194.  
  195.     The  standard  output  from  a command enclosed between grave
  196. accents ( `` `` )
  197.     may be used as part or all of a word; trailing  newlines  are
  198. removed.
  199.  
  200.     No  interpretation  is  done on the command string before the
  201. string is
  202.     read, except to remove backslashes  ( used  to  escape  other
  203. characters.
  204.     Backslashes  may be used to escape grave accents (``) or other
  205. backslashes
  206.     and are removed before the command string is read.   Escaping
  207. grave
  208.     accents  allows  nested command substitution.  If the command
  209. substitution
  210.     lies within a pair of double quotes ( "" `` ...... ``  ""  ),  back-
  211. slashes used to
  212.     escape a double quote (
  213.     intact.
  214.  
  215.     If  a  backslash  is used to escape a newline character, both
  216. the backslash
  217.     and the newline are removed (see the section on ``Quoting'').
  218. In addi-
  219.     tion,  backslashes  used  to  escape  dollar  signs  ($ ) are
  220. removed.  Since
  221.     no interpretation is done on the command string before it  is
  222. read,
  223.     inserting  a backslash to escape a dollar sign has no effect.
  224. Backslashes
  225.     that precede characters other than ``, "", nneewwlliinnee, and  $$  are
  226. left
  227.     intact.
  228.  
  229.     _P_a_r_a_m_e_t_e_r _s_u_b_s_t_i_t_u_t_i_o_n
  230.  
  231.     The   character   $$   is   used  to  introduce  substitutable
  232. _p_a_r_a_m_e_t_e_r_s.  There are
  233.     two  types  of  parameters,  positional  and   keyword.    If
  234. _p_a_r_a_m_e_t_e_r is a
  235.     digit,  it  is  a positional parameter. Positional parameters
  236. may be
  237.     assigned values by sseett.  Keyword parameters, (also  known  as
  238. variables)
  239.     may be assigned values by writing:
  240.  
  241.        _nn_aa_mm_ee _== _vv_aa_ll_uu_ee [ _nn_aa_mm_ee _== _vv_aa_ll_uu_ee ] ...
  242.  
  243.     Pattern-matching  is not performed on _vv_aa_ll_uu_ee.  There cannot be
  244. a function
  245.     and a variable with the same name.
  246.  
  247.     $${{_pp_aa_rr_aa_mm_ee_tt_ee_rr}}
  248.          A _pp_aa_rr_aa_mm_ee_tt_ee_rr is a sequence of letters, digits, or  under-
  249. scores (a
  250.          _n_a_m_e),  a digit, or any of the characters **, @@, ##, ??, --,
  251. $$, and !!.
  252.          The value, if any, of the parameter is substituted.  The
  253. braces are
  254.          required  only  when  _pp_aa_rr_aa_mm_ee_tt_ee_rr is followed by a letter,
  255. digit, or
  256.          underscore that is not to be interpreted as part of  its
  257. name.  A
  258.          _n_a_m_e  must  begin  with  a  letter  or  underscore.   If
  259. _pp_aa_rr_aa_mm_ee_tt_ee_rr is a
  260.          digit then it is a positional parameter.   If  _pp_aa_rr_aa_mm_ee_tt_ee_rr
  261. is ** or @@,
  262.          then  all  the  positional parameters, starting with $$11,
  263. are substi-
  264.          tuted (separated by spaces).  Parameter $$00 is  set  from
  265. argument zero
  266.          when the shell is invoked.
  267.  
  268.     $${{_pp_aa_rr_aa_mm_ee_tt_ee_rr::--_ww_oo_rr_dd}}
  269.          If  _pp_aa_rr_aa_mm_ee_tt_ee_rr is set and is not a null argument, substi-
  270. tute its
  271.          value; otherwise substitute _ww_oo_rr_dd.
  272.  
  273.     $${{_pp_aa_rr_aa_mm_ee_tt_ee_rr::==_ww_oo_rr_dd}}
  274.          If _pp_aa_rr_aa_mm_ee_tt_ee_rr is not set or is null, then set it to _ww_oo_rr_dd;
  275. the value
  276.          of the parameter is then substituted.  Positional param-
  277. eters may not
  278.          be assigned to in this way.
  279.  
  280.     $${{_pp_aa_rr_aa_mm_ee_tt_ee_rr::??_ww_oo_rr_dd}}
  281.          If _pp_aa_rr_aa_mm_ee_tt_ee_rr is set and is not a null argument,  substi-
  282. tute its
  283.          value;  otherwise,  print  _ww_oo_rr_dd and exit from the shell.
  284. If _ww_oo_rr_dd is
  285.          omitted, the message ``parameter null or  not  set''  is
  286. printed.
  287.  
  288.     $${{_pp_aa_rr_aa_mm_ee_tt_ee_rr::++_ww_oo_rr_dd}}
  289.          If  _pp_aa_rr_aa_mm_ee_tt_ee_rr is set and is not a null argument, substi-
  290. tute _ww_oo_rr_dd;
  291.          otherwise substitute nothing.
  292.  
  293.     In the above, _ww_oo_rr_dd is not evaluated unless it is to  be  used
  294. as the sub-
  295.     stituted  string,  so  that  in the following example, ppwwdd is
  296. executed only
  297.     if dd is not set or is null:
  298.  
  299.        eecchhoo  $${{dd::--((ggaappwwdd``}}
  300.  
  301.     If the colon (::) is omitted from the above expressions,  then
  302. the shell
  303.     only checks whether _pp_aa_rr_aa_mm_ee_tt_ee_rr is set.
  304.  
  305.     The following parameters are automatically set by the shell:
  306.  
  307.     ##    The number of positional parameters in decimal
  308.  
  309.     --     Flags supplied to the shell on invocation or by the sseett
  310. command
  311.  
  312.     ??    The decimal value returned  by  the  last  synchronously
  313. executed com-
  314.          mand
  315.  
  316.     $$    The process number of this shell
  317.  
  318.     !!     The  process  number  of  the  last  background command
  319. invoked
  320.  
  321.     The following parameters are used by the shell:
  322.  
  323.     CCDDPPAATTHH        Defines search path for the  ccdd  command.   See
  324. the section
  325.                   ``cd'' under ``Special commands'' below.
  326.  
  327.     HHOOMMEE           The  default argument (home directory) for the
  328. ccdd command
  329.  
  330.     PPAATTHH          The search path for commands (see ``Execution''
  331. below)
  332.  
  333.     MMAAIILL           If  this variable is set to the name of a mail
  334. file, then
  335.                   the shell informs the user of  the  arrival  of
  336. mail in the
  337.                   specified file
  338.  
  339.     MMAAIILLCCHHEECCKK     This parameter specifies how often (in seconds)
  340. the shell
  341.                   will check for the arrival of mail in the files
  342. specified
  343.                   by   the  MMAAIILLPPAATTHH  or  MMAAIILL  parameters.   The
  344. default value is
  345.                   600 seconds (10 minutes).  If  set  to  0,  the
  346. shell will
  347.                   check before each prompt.
  348.  
  349.     MMAAIILLPPAATTHH       A  colon  ((::)) separated list of filenames.  If
  350. this parameter
  351.                   is set, the  shell  informs  the  user  of  the
  352. arrival of mail
  353.                   in  any  of the specified files.  Each filename
  354. can be fol-
  355.                   lowed by ``%''  and  a  message  that  will  be
  356. printed when the
  357.                   modification time changes.  The default message
  358. is
  359.                   ``you have mail''.
  360.  
  361.     PPSS11           Primary prompt string, by default ``$$ ''
  362.  
  363.     PPSS22           Secondary prompt string, by default ``>> ''
  364.  
  365.     IIFFSS           Internal field separators, normally ssppaaccee, ttaabb,
  366. and nneewwlliinnee
  367.  
  368.     SSHHEELLLL          When  the shell is invoked, it scans the envi-
  369. ronment (see
  370.                   ``Environment'' below) for this name.  If it is
  371. found and
  372.                   there  is  an  `r' in the file name part of its
  373. value, the
  374.                   shell becomes a restricted shell.
  375.  
  376.     The shell gives default values to PPAATTHH, PPSS11,  PPSS22,  and  IIFFSS,
  377. while HHOOMMEE and
  378.     MMAAIILL are not set at all by the shell (although HHOOMMEE _i_s set by
  379. llooggiinn(M)).
  380.  
  381.     _B_l_a_n_k _i_n_t_e_r_p_r_e_t_a_t_i_o_n
  382.  
  383.     After parameter and command substitution, the results of sub-
  384. stitution are
  385.     scanned  for internal field separator characters (those found
  386. in IIFFSS) and
  387.     split into  distinct  arguments  where  such  characters  are
  388. found.  Explicit
  389.     null  arguments  (  """"  or  '''' ) are retained.  Implicit null
  390. arguments (those
  391.     resulting from _pp_aa_rr_aa_mm_ee_tt_ee_rr_ss that have no values) are removed.
  392.  
  393.     _F_i_l_e_n_a_m_e _g_e_n_e_r_a_t_i_o_n
  394.  
  395.     Following substitution, each command _ww_oo_rr_dd is scanned for  the
  396. characters
  397.     **, ??, and [[.  If one of these characters appears, the word is
  398. regarded as
  399.     a _pp_aa_tt_tt_ee_rr_nn.  The word is replaced with  alphabetically  sorted
  400. filenames
  401.     that match the pattern.  If no filename is found that matches
  402. the pat-
  403.     tern, the word is left unchanged.  The character ``.'' at the
  404. start of a
  405.     filename  or  immediately  following  a ``/'', as well as the
  406. character ``/''
  407.     itself, must be  matched  explicitly.  These  characters  and
  408. their matching
  409.     patterns are:
  410.  
  411.     **     Matches any string, including the null string.
  412.  
  413.     ??     Matches any single character.
  414.  
  415.     [[...]]  Matches any one of the enclosed characters.  A pair of
  416. characters
  417.           separated by  ``-''  matches  any  character  lexically
  418. between the
  419.           pair,  inclusive.  If the first character following the
  420. opening
  421.           bracket ([[) is an exclamation mark (!!), then any  char-
  422. acter not
  423.           enclosed is matched.
  424.  
  425.     _Q_u_o_t_i_n_g
  426.  
  427.     The  following characters have a special meaning to the shell
  428. and cause
  429.     termination of a word unless quoted:
  430.  
  431.        ;  &  (  )  |  ^  <  >  newline  space  tab
  432.  
  433.     A character may be _q_u_o_t_e_d (that is, made to stand for itself)
  434. by preced-
  435.     ing it with a ``''.  The pairneewwlliinnee is ignored.  All charac-
  436. ters
  437.     enclosed between a pair of  single  quotation  marks  (''  ''),
  438. except a single
  439.     quotation mark, are quoted.  Inside double quotation marks (""
  440. ""), parame-
  441.     ter and command substitution occurs and ``'' quotes the char-
  442. acters ``,
  443.     "", and $$.  ""$$**"" is equivalent to ""$$11 $$22 ..."", whereas ""$$@@"" is
  444. equivalent
  445.     to ""$$11"" ""$$22"" ...
  446.  
  447.     _P_r_o_m_p_t_i_n_g
  448.  
  449.     When used interactively, the shell prompts with the value  of
  450. PPSS11 before
  451.     reading  a  command.   If  at any time a newline is typed and
  452. further input
  453.     is needed to complete a command, the secondary  prompt  (that
  454. is, the value
  455.     of PPSS22) is issued.
  456.  
  457.     _S_p_e_l_l_i_n_g _c_h_e_c_k_e_r
  458.  
  459.     When  using ccdd(C) the shell checks spelling.  For example, if
  460. you change
  461.     to a different directory using ccdd and misspell the  directory
  462. name, the
  463.     shell  responds  with  an alternative spelling of an existing
  464. directory.
  465.     Enter ``y'' and press <Return> (or just  press  <Return>)  to
  466. change to the
  467.     offered  directory.   If  the  offered spelling is incorrect,
  468. enter ``n'',
  469.     then retype the command line.   In  this  example  the  sshh(C)
  470. response is
  471.     boldfaced:
  472.  
  473.        $ cd /usr/spol/uucp
  474.        ccdd //uussrr//ssppooooll//uuuuccpp??y
  475.        ookk
  476.  
  477.  
  478.     _I_n_p_u_t/_O_u_t_p_u_t
  479.  
  480.     Before  a  command  is  executed, its input and output may be
  481. redirected
  482.     using a special notation interpreted by the shell.  The  fol-
  483. lowing may
  484.     appear  anywhere in a simple-command or may precede or follow
  485. a command.
  486.     They are _n_o_t passed on to the invoked  command;  substitution
  487. occurs before
  488.     _ww_oo_rr_dd or _dd_ii_gg_ii_tt is used:
  489.  
  490.     <<_ww_oo_rr_dd          Use file _ww_oo_rr_dd as standard input (file descrip-
  491. tor 0).
  492.  
  493.     >>_ww_oo_rr_dd         Use file _ww_oo_rr_dd as standard output (file descrip-
  494. tor 1).  If
  495.                   the  file does not exist, it is created; other-
  496. wise, it is
  497.                   truncated to zero length.
  498.  
  499.     >>>>_ww_oo_rr_dd        Use file _ww_oo_rr_dd as standard output.  If the  file
  500. exists, out-
  501.                   put  is  appended  to  it (by first seeking the
  502. end-of-file);
  503.                   otherwise, the file is created.
  504.  
  505.     <<<<[--]_ww_oo_rr_dd     The shell input is read up to a  line  that  is
  506. the same as
  507.                   _ww_oo_rr_dd, or to an end-of-file.  The resulting doc-
  508. ument becomes
  509.                   the standard input.  If any character  of  _ww_oo_rr_dd
  510. is quoted, no
  511.                   interpretation is placed upon the characters of
  512. the docu-
  513.                   ment; otherwise, parameter and command  substi-
  514. tution occurs,
  515.                   (unescaped)neewwlliinnee is ignored, and ``'' must be
  516. used to
  517.                   quote the characters $$, ``, and the first  char-
  518. acter of
  519.                   _ww_oo_rr_dd.   If ``-'' is appended to <<<<, all leading
  520. tabs are
  521.                   stripped from _ww_oo_rr_dd and from the document.
  522.  
  523.     <<&&_dd_ii_gg_ii_tt       The standard  input  is  duplicated  from  file
  524. descriptor _dd_ii_gg_ii_tt
  525.                   (see  dduupp(S)).  Similarly for the standard out-
  526. put using >>.
  527.  
  528.     <<&&--           The standard input is  closed.   Similarly  for
  529. the standard
  530.                   output using >>.
  531.  
  532.     If one of the above is preceded by a digit, the file descrip-
  533. tor created
  534.     is that specified by the digit (instead of the default  0  or
  535. 1).  For
  536.     example:
  537.  
  538.        ...... 22>>&&11
  539.  
  540.     creates  file  descriptor  2  that  is  a  duplicate  of file
  541. descriptor 1.
  542.  
  543.     If a command is followed by ``&'', the default standard input
  544. for the
  545.     command is the empty file /_d_e_v/_n_u_l_l.  Otherwise, the environ-
  546. ment for the
  547.     execution of a command contains the file descriptors  of  the
  548. invoking
  549.     shell as modified by input/output specifications.
  550.  
  551.     _E_n_v_i_r_o_n_m_e_n_t
  552.  
  553.     The  _e_n_v_i_r_o_n_m_e_n_t  (see  eennvviirroonn(M))  is  a list of name-value
  554. pairs that is
  555.     passed to an executed program in the same  way  as  a  normal
  556. argument list.
  557.     The shell interacts with the environment in several ways.  On
  558. invocation,
  559.     the shell scans the environment and creates a  parameter  for
  560. each name
  561.     found,  giving it the corresponding value.  Executed commands
  562. inherit the
  563.     same environment.  If the user modifies the values  of  these
  564. parameters or
  565.     creates new ones, none of these affect the environment unless
  566. the eexxppoorrtt
  567.     command is used to bind the shell's parameter to the environ-
  568. ment.  The
  569.     environment  seen  by any executed command is composed of any
  570. unmodified
  571.     name-value pairs originally inherited by the shell, minus any
  572. pairs
  573.     removed by uunnsseett, plus any modifications or additions, all of
  574. which must
  575.     be noted in eexxppoorrtt commands.
  576.  
  577.     The environment for any _s_i_m_p_l_e-_c_o_m_m_a_n_d may  be  augmented  by
  578. prefixing it
  579.     with one or more assignments to parameters.  Thus:
  580.  
  581.        TTEERRMM==wwyy6600 _cc_mm_dd _aa_rr_gg_ss
  582.  
  583.     and
  584.  
  585.        (eexxppoorrtt TTEERRMM; TTEERRMM==wwyy6600; _cc_mm_dd _aa_rr_gg_ss)
  586.  
  587.     are  equivalent (as far as the above execution of _cc_mm_dd is con-
  588. cerned).
  589.  
  590.     If the --kk flag is set, _a_l_l keyword arguments  are  placed  in
  591. the environ-
  592.     ment, even if they occur after the command name.
  593.  
  594.     _S_i_g_n_a_l_s
  595.  
  596.     The  IINNTTEERRRRUUPPTT  and  QQUUIITT  signals for an invoked command are
  597. ignored if the
  598.     command is followed by ``&''; otherwise signals have the val-
  599. ues inherited
  600.     by  the  shell  from its parent, with the exception of signal
  601. 11.  See the
  602.     ttrraapp command below.
  603.  
  604.     _E_x_e_c_u_t_i_o_n
  605.  
  606.     Each time a command is executed, the above substitutions  are
  607. carried out.
  608.     If  the  command  name  does not match a _s_p_e_c_i_a_l _c_o_m_m_a_n_d, but
  609. matches the
  610.     name of a defined function, the function is executed  in  the
  611. shell process
  612.     (note  how  this  differs  from the execution of shell proce-
  613. dures). The posi-
  614.     tional parameters $$11,, $$22, ... are set to the arguments of the
  615. function.
  616.     If the command name matches neither a _s_p_e_c_i_a_l _c_o_m_m_a_n_d nor the
  617. name of a
  618.     defined function, a new process is created and an attempt  is
  619. made to exe-
  620.     cute the command via eexxeecc(S).
  621.  
  622.     The  shell  parameter  PPAATTHH  defines  the search path for the
  623. directory con-
  624.     taining the command.  Alternative directory names  are  sepa-
  625. rated by a
  626.     colon  (::).   The  default path is :/_b_i_n:/_u_s_r/_b_i_n (specifying
  627. the current
  628.     directory, /_b_i_n, and /_u_s_r/_b_i_n, in that order).  Note that the
  629. current
  630.     directory  is  specified by a null pathname, which can appear
  631. immediately
  632.     after the equal sign or between the colon delimiters anywhere
  633. else in the
  634.     path  list.   If  the command name contains a ``/'', then the
  635. search path is
  636.     not used.  Otherwise, each directory in the path is  searched
  637. for an exe-
  638.     cutable  file.  If the file has execute permission but is not
  639. an _a._o_u_t
  640.     file, it is assumed to be a file containing  shell  commands.
  641. A subshell
  642.     (that  is,  a  separate  process)  is  spawned to read it.  A
  643. parenthesized
  644.     command is also executed in a subshell.
  645.  
  646.     Shell procedures are often used by  users  running  the  ccsshh.
  647. However, if
  648.     the  first  character  of  the  procedure is a ``#'' (comment
  649. character), ccsshh
  650.     assumes the procedure is a ccsshh script, and  invokes  //bbiinn//ccsshh
  651. to execute
  652.     it.  Always  start sshh procedures with some other character if
  653. ccsshh users are
  654.     to run the procedure at any time.  This invokes the  standard
  655. shell
  656.     //bbiinn//sshh.
  657.  
  658.     The  location in the search path where a command was found is
  659. remembered
  660.     by the shell (to help avoid unnecessary eexxeeccs later).  If the
  661. command was
  662.     found  in  a  relative  directory,  its  location must be re-
  663. determined when-
  664.     ever the current directory changes.  The  shell  forgets  all
  665. remembered
  666.     locations  whenever  the PPAATTHH variable is changed or the hhaasshh
  667. --rr command is
  668.     executed (see hhaasshh in next section).
  669.  
  670.     _S_p_e_c_i_a_l _c_o_m_m_a_n_d_s
  671.  
  672.     Input/output redirection is permitted for these commands:
  673.  
  674.     ::    No effect; the command does nothing.  A zero  exit  code
  675. is returned.
  676.  
  677.     .. _ff_ii_ll_ee
  678.          Reads  and executes commands from _ff_ii_ll_ee and returns.  The
  679. search path
  680.          specified by PPAATTHH is used to find the directory contain-
  681. ing _ff_ii_ll_ee.
  682.  
  683.     bbrreeaakk [ _nn ]
  684.          Exits  from  the enclosing ffoorr, wwhhiillee, or uunnttiill loop, if
  685. any.  If _nn is
  686.          specified, it breaks _nn levels.
  687.  
  688.     ccoonnttiinnuuee [ _nn ]
  689.          Resumes the next iteration of the enclosing ffoorr,  wwhhiillee,
  690. or uunnttiill
  691.          loop.  If _nn is specified, it resumes at the _nn-th enclos-
  692. ing loop.
  693.  
  694.     ccdd [ _aa_rr_gg ]
  695.          Changes the current directory to _aa_rr_gg.  The shell parame-
  696. ter HHOOMMEE is
  697.          the default _aa_rr_gg.  The shell parameter CCDDPPAATTHH defines the
  698. search path
  699.          for the directory containing _aa_rr_gg.  Alternative directory
  700. names are
  701.          separated  by  a  colon (:).  The default path is <null>
  702. (specifying
  703.          the current directory).  Note that the current directory
  704. is speci-
  705.          fied  by  a null path name, which can appear immediately
  706. after the
  707.          equal sign or between the colon delimiters anywhere else
  708. in the path
  709.          list.   If  _aa_rr_gg  begins with a ``/'', the search path is
  710. not used.
  711.          Otherwise, each directory in the path  is  searched  for
  712. _aa_rr_gg.
  713.  
  714.          If  the  shell  is reading its commands from a terminal,
  715. and the speci-
  716.          fied directory does not exist (or some component  cannot
  717. be
  718.          searched), spelling correction is applied to each compo-
  719. nent of
  720.          _d_i_r_e_c_t_o_r_y, in a search for the  ``correct''  name.   The
  721. shell then
  722.          asks  whether  or not to try and change directory to the
  723. corrected
  724.          directory name; an answer of nn means  ``no'',  and  any-
  725. thing else is
  726.          taken as ``yes''.
  727.  
  728.     eecchhoo [ _aa_rr_gg ]
  729.          Writes arguments separated by blanks and terminated by a
  730. newline on
  731.          the standard  output.   Arguments  may  be  enclosed  in
  732. quotes. bQuotes
  733.         Bare  required  so  that  the  shell correctly interprets
  734. these speacial
  735.         cescape sequences:
  736.         k
  737.         s
  738.         p       f      Form feed
  739.        ran     CNaerwrliiangee return
  740.         c
  741.        te     Tab
  742.               Vertical tab
  743.         \     Backslash
  744.         _nn      The 8-bit character whose ASCII code is the  1,  2
  745. or 3-digit
  746.                  octal number _nn.  _nn must start with a zero.
  747.  
  748.  
  749.     eevvaall [ _aa_rr_gg ... ]
  750.          The  arguments  are  read  as input to the shell and the
  751. resulting
  752.          command(s) executed.
  753.  
  754.     eexxeecc [ _aa_rr_gg ... ]
  755.          The command specified by the arguments  is  executed  in
  756. place of this
  757.          shell  without  creating  a  new  process.  Input/output
  758. arguments may
  759.          appear and, if no other arguments are given,  cause  the
  760. shell
  761.          input/output to be modified.
  762.  
  763.     eexxiitt [ _nn ]
  764.          Causes  the shell to exit with the exit status specified
  765. by _nn.  If _nn
  766.          is omitted, the exit status is that of the last  command
  767. executed.
  768.          An end-of-file will also cause the shell to exit.
  769.  
  770.     eexxppoorrtt [ _nn_aa_mm_ee ... ]
  771.          The  given  _nn_aa_mm_ees are marked for automatic export to the
  772. _e_n_v_i_r_o_n_m_e_n_t
  773.          of subsequently executed commands.  If no arguments  are
  774. given, a
  775.          list  of  all  names  that are exported in this shell is
  776. printed.
  777.  
  778.     ggeettooppttss
  779.          Used in shell scripts to support  command  syntax  stan-
  780. dards (see
  781.          IInnttrroo(C));  it  parses  positional parameters and checks
  782. for legal
  783.          options.  See ggeettooppttss(C) for usage and description.
  784.  
  785.     hhaasshh [ --rr ] [ _nn_aa_mm_ee ... ]
  786.          For each _nn_aa_mm_ee, the location in the search  path  of  the
  787. command speci-
  788.          fied  by _nn_aa_mm_ee is determined and remembered by the shell.
  789. The --rr
  790.          option causes the shell to forget all  remembered  loca-
  791. tions.  If no
  792.          arguments   are   given,  information  about  remembered
  793. commands is
  794.          presented.  ``Hits'' is the number of  times  a  command
  795. has been
  796.          invoked  by the shell process.  ``Cost'' is a measure of
  797. the work
  798.          required to locate a command in the search path.   There
  799. are certain
  800.          situations  which  require that the stored location of a
  801. command be
  802.          recalculated.  Commands for which this will be done  are
  803. indicated by
  804.          an  asterisk  (**)  adjacent to the ``hits'' information.
  805. ``Cost'' will
  806.          be incremented when the recalculation is done.
  807.  
  808.     nneewwggrrpp [ _aa_rr_gg ... ]
  809.          Equivalent to eexxeecc nneewwggrrpp _aa_rr_gg ...
  810.  
  811.     ppwwdd  Print the current working  directory.   See  ppwwdd(C)  for
  812. usage and
  813.          description.
  814.  
  815.     rreeaadd [ _nn_aa_mm_ee ... ]
  816.          One  line  is read from the standard input and the first
  817. word is
  818.          assigned to the first _nn_aa_mm_ee, the second word to the  sec-
  819. ond _nn_aa_mm_ee,
  820.          etc.,  with  leftover  words  assigned to the last _nn_aa_mm_ee.
  821. The return
  822.          code is 0 unless an end-of-file is encountered.
  823.  
  824.     rreeaaddoonnllyy [ _nn_aa_mm_ee ... ]
  825.          The given _nn_aa_mm_ees are marked rreeaaddoonnllyy and  the  values  of
  826. these _nn_aa_mm_ees
  827.          may  not  be  changed  by  subsequent assignment.  If no
  828. arguments are
  829.          given, a list of all rreeaaddoonnllyy names is printed.
  830.  
  831.     rreettuurrnn [ _nn ]
  832.          Causes a function to exit with the return  value  speci-
  833. fied by _nn.  If
  834.          _nn is omitted, the return status is that of the last com-
  835. mand
  836.          executed.
  837.  
  838.     sseett [ --aaeeffhhkknnuuvvxx [ _aa_rr_gg ... ] ]
  839.  
  840.          --aa  Mark variables which are  modified  or  created  for
  841. export.
  842.          --ee  If the shell is noninteractive, exits immediately if
  843. a command
  844.              exits with a nonzero exit status.
  845.          --ff  Disables filename generation.
  846.          --hh  Locates and remembers function commands as functions
  847. are defined
  848.              (function  commands  are  normally  located when the
  849. function is
  850.              executed).  For example, if hh is  set,  /_b_i_n/_t_t_y  is
  851. added to the
  852.              hash table when:
  853.  
  854.              showtty(){
  855.                  tty
  856.              }
  857.  
  858.              is  declared.  If  hh  is  unset, the function is not
  859. added to the
  860.              hash table until showtty is called.
  861.          --kk  Places all keyword arguments in the environment  for
  862. a command,
  863.              not just those that precede the command name.
  864.          --nn  Reads commands but does not execute them.
  865.          --uu   Treats  unset variables as an error when substitut-
  866. ing.
  867.          --vv  Prints shell input lines as they are read.
  868.          --xx  Prints commands and their arguments as they are exe-
  869. cuted.
  870.              Although  this  flag is passed to subshells, it does
  871. not enable
  872.              tracing in those subshells.
  873.          ----  Does not change any of the flags; useful in  setting
  874. $1 to ``-''.
  875.  
  876.              Using  ``+'' rather than ``-'' causes these flags to
  877. be turned
  878.              off.  These flags can also be used  upon  invocation
  879. of the shell.
  880.              The  current  set  of flags may be found in $$--.  The
  881. remaining
  882.              arguments  are   positional   parameters   and   are
  883. assigned, in order,
  884.              to  $$11, $$22, ...  If no arguments are given, the val-
  885. ues of all
  886.              names are printed.
  887.  
  888.     sshhiifftt [_nn]
  889.          The positional parameters from $$22 ...   are  renamed  $$11
  890. ... If _nn is
  891.          specified,  shift the positional parameters by _nn places.
  892. sshhiifftt is the
  893.          only way to access positional parameters above $$99.
  894.  
  895.     tteesstt Evaluates conditional expressions. See tteesstt(C) for usage
  896. and
  897.          description.
  898.  
  899.     ttiimmeess
  900.          Prints  the  accumulated  user and system times for pro-
  901. cesses run from
  902.          the shell.
  903.  
  904.     ttrraapp [ _aa_rr_gg ] [ _nn ] ...
  905.          _aa_rr_gg is a command to be read and executed when the  shell
  906. receives
  907.          signal(s)  _nn.   (Note  that _aa_rr_gg is scanned once when the
  908. trap is set
  909.          and once when the trap is  taken.)   Trap  commands  are
  910. executed in
  911.          order  of  signal  number.   The  highest  signal number
  912. allowed is 16.
  913.          Any attempt to set a trap on a signal that  was  ignored
  914. on entry to
  915.          the current shell is ineffective.  An attempt to trap on
  916. signal 11
  917.          (memory fault) produces an error.  If _aa_rr_gg is absent, all
  918. trap(s) _nn
  919.          are  reset to their original values.  If _aa_rr_gg is the null
  920. string, this
  921.          signal is ignored by the shell and by  the  commands  it
  922. invokes.  If _nn
  923.          is  0,  the  command  _aa_rr_gg  is  executed on exit from the
  924. shell.  The ttrraapp
  925.          command with no arguments  prints  a  list  of  commands
  926. associated with
  927.          each signal number.
  928.  
  929.     ttyyppee [ _nn_aa_mm_ee ... ]
  930.          For  each  _nn_aa_mm_ee, indicate how it would be interpreted if
  931. used as a
  932.          command name.
  933.  
  934.     uulliimmiitt [ _nn ]
  935.          imposes a size limit of _nn blocks on files written by the
  936. shell and
  937.          its child processes (files of any size may be read). Any
  938. user may
  939.          decrease the file size limit, but only  the  super  user
  940. (_r_o_o_t) can
  941.          increase the limit.  With no argument, the current limit
  942. is printed.
  943.          If no option is given and a number is specified,  --ff  is
  944. assumed.
  945.  
  946.     uunnsseett [ _nn_aa_mm_ee ... ]
  947.          For  each  _nn_aa_mm_ee,  remove  the  corresponding variable or
  948. function.  The
  949.          variables PPAATTHH, PPSS11, PPSS22, MMAAIILLCCHHEECCKK and  IIFFSS  cannot  be
  950. unset.
  951.  
  952.     uummaasskk [ _oo_oo_oo ]
  953.          The  user  file-creation mask is set to the octal number
  954. _oo_oo_oo where _oo
  955.          is an octal digit (see uummaasskk(C)).  If  _oo_oo_oo  is  omitted,
  956. the current
  957.          value of the mask is printed.
  958.  
  959.     wwaaiitt [ _nn ]
  960.          Waits  for  the  specified  process  to  terminate,  and
  961. reports the termi-
  962.          nation status.  If _nn is not given, all currently  active
  963. child pro-
  964.          cesses  are  waited for.  The return code from this com-
  965. mand is always
  966.          0.
  967.  
  968.     _I_n_v_o_c_a_t_i_o_n
  969.  
  970.     If the shell is invoked through eexxeecc(S) and the first charac-
  971. ter of argu-
  972.     ment   0   is   ``-'',   commands  are  initially  read  from
  973. /_e_t_c/_p_r_o_f_i_l_e and then
  974.     from $$HHOOMMEE/._p_r_o_f_i_l_e, if such files exist.   Thereafter,  com-
  975. mands are read
  976.     as  described below, which is also the case when the shell is
  977. invoked as
  978.     //bbiinn//sshh.  The flags below are interpreted  by  the  shell  on
  979. invocation
  980.     only;  note  that  unless the --cc or --ss flag is specified, the
  981. first argument
  982.     is assumed to be the name of a file containing commands,  and
  983. the remain-
  984.     ing  arguments  are  passed  as positional parameters to that
  985. command file:
  986.  
  987.     --cc _ss_tt_rr_ii_nn_gg If the --cc flag is present, commands are  read  from
  988. _ss_tt_rr_ii_nn_gg.
  989.  
  990.     --ss         If  the  --ss  flag  is  present  or if no arguments
  991. remain, commands
  992.               are read from the standard  input.   Any  remaining
  993. arguments
  994.               specify the positional parameters.  Shell output is
  995. written to
  996.               file descriptor 2.
  997.  
  998.     --tt        If the --tt flag is present, a single command is read
  999. and exe-
  1000.               cuted,  and the shell exits.  This flag is intended
  1001. for use by C
  1002.               programs only and is not useful interactively.
  1003.  
  1004.     --ii        If the --ii flag is present or if the shell input and
  1005. output are
  1006.               attached  to a terminal, this shell is _i_n_t_e_r_a_c_t_i_v_e.
  1007. In this
  1008.               case, TTEERRMMIINNAATTEE is ignored (so that kkiillll 00 does not
  1009. kill an
  1010.               interactive  shell)  and  IINNTTEERRRRUUPPTT  is  caught and
  1011. ignored (so that
  1012.               wwaaiitt is interruptible).   In  all  cases,  QQUUIITT  is
  1013. ignored by the
  1014.               shell.
  1015.  
  1016.     --rr         If  the  --rr  flag  is  present,  the  shell  is  a
  1017. restricted shell (see
  1018.               rrsshh(C)).
  1019.  
  1020.     The remaining flags and arguments are described under the sseett
  1021. command
  1022.     above.
  1023.  
  1024.  _E_x_i_t _s_t_a_t_u_s
  1025.  
  1026.     Errors  detected  by  the shell, such as syntax errors, cause
  1027. the shell to
  1028.     return a nonzero exit status.  If the  shell  is  being  used
  1029. noninterac-
  1030.     tively, execution of the shell file is abandoned.  Otherwise,
  1031. the shell
  1032.     returns the exit status of the last command executed. See the
  1033. eexxiitt com-
  1034.     mand above.
  1035.  
  1036.  _F_i_l_e_s
  1037.  
  1038.     /_e_t_c/_p_r_o_f_i_l_e    system  default _p_r_o_f_i_l_e, read by login shells
  1039. before
  1040.                    $$HHOOMMEE/._p_r_o_f_i_l_e
  1041.     $$HHOOMMEE/._p_r_o_f_i_l_e read by login shell at login
  1042.     /_t_m_p/_s_h*       temporary file for <<<<
  1043.     /_d_e_v/_n_u_l_l      source of empty file
  1044.  
  1045.  _S_e_e _a_l_s_o
  1046.  
  1047.     aa..oouutt(FP),  ccdd(C),  dduupp(S),  eennvv(C),   eennvviirroonn(M),   eexxeecc(S),
  1048. ffoorrkk(S), kksshh(C),
  1049.     llooggiinn(M),  nneewwggrrpp(C), ppiippee(S), pprrooffiillee(M), rrsshh(C), ssiiggnnaall(S),
  1050. tteesstt(C),
  1051.     uummaasskk(C), uummaasskk(S) and wwaaiitt(S).
  1052.  
  1053.  _N_o_t_e_s
  1054.  
  1055.     The command rreeaaddoonnllyy (without arguments)  produces  the  same
  1056. type of output
  1057.     as the command eexxppoorrtt.
  1058.  
  1059.     If  <<<<  is  used to provide standard input to an asynchronous
  1060. process
  1061.     invoked by &&, the shell gets mixed up about naming the  input
  1062. document; a
  1063.     garbage  file  /_t_m_p/_s_h*  is  created  and the shell complains
  1064. about not being
  1065.     able to find that file by another name.
  1066.  
  1067.     If a command is executed, and a command with the same name is
  1068. installed
  1069.     in  a directory in the search path before the directory where
  1070. the original
  1071.     command was found, the shell will continue to eexxeecc the origi-
  1072. nal command.
  1073.     Use the hhaasshh command to correct this situation.
  1074.  
  1075.     If  you  move  the current directory or one above it, ppwwdd may
  1076. not give the
  1077.     correct response.  Use the ccdd command with a full pathname to
  1078. correct
  1079.     this situation.
  1080.  
  1081.     When  a  sshh  user logs in, the system reads and executes com-
  1082. mands in
  1083.     /_e_t_c/_p_r_o_f_i_l_e  before  executing  commands   in   the   user's
  1084. $$HHOOMMEE/._p_r_o_f_i_l_e.  You
  1085.     can,  therefore,  modify  the environment for all sshh users on
  1086. the system by
  1087.     editing /_e_t_c/_p_r_o_f_i_l_e.
  1088.  
  1089.     The shell doesn't treat the high (eighth) bit in the  charac-
  1090. ters of a com-
  1091.     mand  line  argument  specially, nor does it strip the eighth
  1092. bit from the
  1093.     characters of error messages.  Previous versions of the shell
  1094. used the
  1095.     eighth bit as a quoting mechanism.
  1096.  
  1097.     Existing  programs  that  set the eighth bit of characters in
  1098. order to quote
  1099.     them as part of the shell command line should be  changed  to
  1100. use of the
  1101.     standard shell quoting mechanisms (see the section on ``Quot-
  1102. ing'').
  1103.  
  1104.     Words used to specify filenames in  input/output  redirection
  1105. are not
  1106.     expanded  for filename generation (see the section on ``File-
  1107. name
  1108.     generation'').  For example, ccaatt ffiillee11 >>  aa**  will  create  a
  1109. file named _a*.
  1110.  
  1111.     Because  commands in pipelines are run as separate processes,
  1112. variables
  1113.     set in a pipeline have no effect on the parent shell.
  1114.  
  1115.     If you get the error message:
  1116.  
  1117.        fork failed - too many processes
  1118.  
  1119.     try using the wwaaiitt(C) command to  clean  up  your  background
  1120. processes.  If
  1121.     this  doesn't help, the system process table is probably full
  1122. or you have
  1123.     too many active foreground processes (there is a limit to the
  1124. number of
  1125.     processes  that  be  can  associated with your login, and the
  1126. number the sys-
  1127.     tem can keep track of).
  1128.  
  1129.  _W_a_r_n_i_n_g_s
  1130.  
  1131.     Not all processes of a 3 or more stage pipeline are  children
  1132. of the
  1133.     shell, and thus cannot be waited for.
  1134.  
  1135.     For  wwaaiitt  _nn,  if  _nn  is  not  an active process id, all your
  1136. shell's currently
  1137.     active background processes are waited  for  and  the  return
  1138. code will be
  1139.     zero.
  1140.  
  1141.  _S_t_a_n_d_a_r_d_s _c_o_n_f_o_r_m_a_n_c_e
  1142.  
  1143.     sshh is conformant with:
  1144.  
  1145.     AT&T SVID Issue 2;
  1146.     and X/Open Portability Guide, Issue 3, 1989.
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.